home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / lpq / RCS / lpq.c,v < prev   
Encoding:
Text File  |  1990-09-24  |  2.1 KB  |  127 lines

  1. head     1.2;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.2
  10. date     90.09.24.14.38.08;  author douglis;  state Exp;
  11. branches ;
  12. next     1.1;
  13.  
  14. 1.1
  15. date     88.11.23.10.31.05;  author rab;  state Exp;
  16. branches ;
  17. next     ;
  18.  
  19.  
  20. desc
  21. @@
  22.  
  23.  
  24. 1.2
  25. log
  26. @added extern declaration to get to compile
  27. @
  28. text
  29. @/*
  30.  * Copyright (c) 1983 Regents of the University of California.
  31.  * All rights reserved.  The Berkeley software License Agreement
  32.  * specifies the terms and conditions for redistribution.
  33.  */
  34.  
  35. #ifndef lint
  36. char copyright[] =
  37. "@@(#) Copyright (c) 1983 Regents of the University of California.\n\
  38.  All rights reserved.\n";
  39. #endif not lint
  40.  
  41. #ifndef lint
  42. static char sccsid[] = "@@(#)lpq.c    5.3 (Berkeley) 4/30/87";
  43. #endif not lint
  44.  
  45. /*
  46.  * Spool Queue examination program
  47.  *
  48.  * lpq [-l] [-Pprinter] [user...] [job...]
  49.  *
  50.  * -l long output
  51.  * -P used to identify printer as per lpr/lprm
  52.  */
  53.  
  54. #include "lp.h"
  55.  
  56. char    *user[MAXUSERS];    /* users to process */
  57. int    users;            /* # of users in user array */
  58. int    requ[MAXREQUESTS];    /* job number of spool entries */
  59. int    requests;        /* # of spool requests */
  60. static void usage();
  61. int debug;
  62.  
  63. main(argc, argv)
  64.     register int    argc;
  65.     register char    **argv;
  66. {
  67.     extern char    *optarg;
  68.     extern int    optind;
  69.     int    ch, lflag;        /* long output option */
  70.  
  71.     name = *argv;
  72.     if (gethostname(host, sizeof(host))) {
  73.         perror("lpq: gethostname");
  74.         exit(1);
  75.     }
  76.     openlog("lpd", 0, LOG_LPR);
  77.  
  78.     lflag = 0;
  79.     while ((ch = getopt(argc, argv, "lP:")) != EOF)
  80.         switch((char)ch) {
  81.         case 'l':            /* long output */
  82.             ++lflag;
  83.             break;
  84.         case 'P':        /* printer name */
  85.             printer = optarg;
  86.             break;
  87.         case '?':
  88.         default:
  89.             usage();
  90.         }
  91.  
  92.     if (printer == NULL && (printer = getenv("PRINTER")) == NULL)
  93.         printer = DEFLP;
  94.  
  95.     for (argc -= optind, argv += optind; argc; --argc, ++argv)
  96.         if (isdigit(argv[0][0])) {
  97.             if (requests >= MAXREQUESTS)
  98.                 fatal("too many requests");
  99.             requ[requests++] = atoi(*argv);
  100.         }
  101.         else {
  102.             if (users >= MAXUSERS)
  103.                 fatal("too many users");
  104.             user[users++] = *argv;
  105.         }
  106.  
  107.     displayq(lflag);
  108.     exit(0);
  109. }
  110.  
  111. static void
  112. usage()
  113. {
  114.     puts("usage: lpq [-l] [-Pprinter] [user ...] [job ...]");
  115.     exit(1);
  116. }
  117. @
  118.  
  119.  
  120. 1.1
  121. log
  122. @Initial revision
  123. @
  124. text
  125. @d33 1
  126. @
  127.